package com.chencs.common.user.service;

import com.chencs.common.user.mapper.UserMapper;
import com.chencs.vo.common.user.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by chencs on 2017/5/26.
 */
@Service
@Transactional
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public String findUserById(String id){

        return userMapper.findUserById(id).getUserName();
    }

    public boolean login(String userCode, String userPwd) {
        Map<String, String> pMap = new HashMap<String, String>();
        pMap.put("userCode", userCode);
        UserModel userModel = userMapper.queryUser(pMap);
        if(userModel!= null && userPwd.equals(userModel.getUserPwd())) {
            return true;
        }
        return  false;
    }

    public List<UserModel> getUsers(){

        return userMapper.userList();
    }
}
